/**
 * Moondance UML modeling tool
 * 
 * @author Dascalu Laurentiu (dascalu.laurentziu@gmail.com).
 * 
 * This program is free software; you can redistribute it and
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package ro.pub.cs.se.moondance.code;

import java.io.ByteArrayInputStream;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;

import ro.pub.cs.se.moondance.MoondanceData;
import ro.pub.cs.se.moondance.model.ClassFunction;
import ro.pub.cs.se.moondance.model.ClassVariable;
import ro.pub.cs.se.moondance.model.UMLClass;

/**
 * Interface must be implemented for each specific language code generator.
 */
public abstract class ICodeGenerator extends Thread {
	public void generateCode() {
		// visibility <<interface>>/<<abstract>> name
	}

	public void generatClass(UMLClass myClass) {
		// visibility <<interface>>/<<abstract>> name
	}

	public void generateAbstractClass(UMLClass myClass) {
		// visibility <<interface>>/<<abstract>> name
	}

	public void generateInterface(UMLClass myClass) {
		// visibility <<interface>>/<<abstract>> name
	}

	public void generateClassVariable(ClassVariable myVar) {
		// visiblity <<static>> name : type[multiplicity] = initialValue
	}

	public void generateClassFunction(ClassFunction myFunc) {
		// visibility <<constructor>>/<<destructor>> <<static>> <<abstract>>
		// name(parameters) : returnType
	}

	protected void createFolders() throws Exception {
	}

	protected void createNewFile(IProject iProj, String name, byte[] data)
			throws Exception {
		if (iProj instanceof IContainer) {
			IContainer container = (IContainer) iProj;
			IFile file = container.getFile(new Path(name));

			if (!file.exists())
				file.create(new ByteArrayInputStream(data), true,
						MoondanceData.DEFAULT_MONITOR);
		}
	}
}
